package basic.xiazheng.reflect;

import java.lang.reflect.Constructor;

/**
 * @创建人 MBY381
 * @创建时间 2022/4/13 13:53
 * @描述 暂无
 */
public class ReflectDemo {
    public static void main(String[] args) throws ReflectiveOperationException {
        getInstance();
    }

    public static void getInstance() throws ReflectiveOperationException {
        Class<Student> clazz = Student.class;
        Constructor<Student> cons = clazz.getConstructor(String.class);
        cons.setAccessible(true);
        Student student = cons.newInstance("what's up");
        student.test();
    }

    static class Student {

        public Student(String str) {
        }

        public void test() {
            System.out.println("萨日朗!");
        }
    }
}

